package com.example.demo.controller.wx;

import com.example.demo.service.wx.impl.WxServiceImpl;
import com.example.demo.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 获取接口调用凭证
 * @author: liyuan
 * @data 2020-11-23 15:45
 */
@RestController
@RequestMapping("/")
public class JsTokenController {

    /***
     *   获取调用凭证： 开发参考微信小程序块
     *   获取："access_token": "","expires_in": 7200
     * @return
     */
    @Autowired
    private WxServiceImpl wxService;

    @RequestMapping("genToken")
    public ResultVO genToken() {
        String token = wxService.getToken();
        if (StringUtils.isEmpty(token)) {
            return ResultVO.fail();
        }
        return new ResultVO(1000, token);
    }

}
